package com.xzy.java.event;

import lombok.extern.slf4j.Slf4j;

/**
 * Java自身对观察者模式的具体实现
 *
 * @author xzy.xiao
 * @date 2023/3/14  10:17
 */
@Slf4j
public class Main {
    public static void main(String[] args) {
        Source source = new Source();
        source.registerListener(myEventObject -> log.info("Listener1 监听到事件 {}", myEventObject));
        source.registerListener(myEventObject -> log.info("Listener2 监听到事件 {}", myEventObject));
        source.registerListener(myEventObject -> log.info("Listener3 监听到事件 {}", myEventObject));

        source.dataChange("aaa");
        source.dataChange("bbb");
        source.dataChange("ccc");
    }
}
